<?php
/**
 * #nt = new_term
 */

//Initialize Nebula Office framework
require_once('../../system.php');
	
//Load commonly used controls
load_basic_controls();
	
//Authenticate the user for the framework
$GO_SECURITY->authenticate();
	
//Authenticate the user for the module
$GO_MODULES->authenticate('term');
	
//Get the language variables
require_once($GO_LANGUAGE->get_language_file('term'));
	
//Require the module class
require_once($GO_MODULES->class_path.'term.class.inc');
$term = new term();
	
//Declare variables
$task = isset($_REQUEST['task']) ? $_REQUEST['task'] : '';

$nb_id = isset($_REQUEST['nb_id']) ? $_REQUEST['nb_id'] : 0;
$return_to = '../business/index.php';
//$return_to = isset($_REQUEST['return_to']) ? $_REQUEST['return_to'] : $_SERVER['HTTP_REFERER'];
$link_back = isset($_REQUEST['link_back']) ? $_REQUEST['link_back'] : $_SERVER['REQUEST_URI'];
	
$form = new form('nt_form');
$form->add_html_element(new input('hidden','term','',false));

$form->add_html_element(new input('hidden', 'clicked_letter'));

if(isset($_REQUEST['nt_type']))
{
	$nt_settings['nt_type'] = $_REQUEST['nt_type'];
	if($_REQUEST['nt_type'] != 'executor')
	{
		$nt_settings['nt_id'] = $_REQUEST['nt_id'];
	}
}else
{
	$nt_settings['nt_type'] = 'executor';
}
	
$tabstrip = new tabstrip('nt_type', '任务设定');
$tabstrip->set_attribute('style','width:100%;height:300px');
$tabstrip->set_return_to(htmlspecialchars($return_to));

$tabstrip->add_tab('executor','执行人');
$tabstrip->add_tab('action_set','动作设定');
$tabstrip->add_tab('prompt_info','提醒信息');
$tabstrip->add_tab('after_action','后续动作');
$tabstrip->set_active_tab($nt_settings['nt_type']);
	
if($tabstrip->submitted)
{
	$datatable->start=0;
}

switch ($nt_settings['nt_type'])
{
	case 'executor':
		require('executor.php');
		$exe = new executor_list('executor_id',1);
		$tabstrip->add_html_element($exe);break;
	case 'prompt_info':	
		$pi_tab = new table();
		$textarea = new textarea('prompt_info','提示信息');
		$textarea->set_attribute('style', 'width:350px;height:150px;');

		$row = new table_row();
		$cell = new table_cell();
		$cell->add_html_element($textarea);
		$row->add_cell($cell);
		$pi_tab->add_row($row);
		$tabstrip->add_html_element($pi_tab);break;
	case 'action_set':
		require('action_set.php');
		$exe = new action_set('executor_id',1);
		$tabstrip->add_html_element($exe);break;		
	case 'after_action':
		require('after_action.php');
		$exe = new after_action('executor_id',1);
		$tabstrip->add_html_element($exe);break;		
	default:
		require('executor.php');
		$exe = new executor_list('executor_id',1);
		$tabstrip->add_html_element($exe);break;
}
$form->add_html_element($tabstrip);
$form->add_html_element(new input('hidden', 'nt_id', $nt_settings['nt_id'], false));
	
	$form->add_html_element(new button($cmdOk, "javascript:document.location='index.php';"));
	$form->add_html_element(new button($cmdApply, "javascript:_save('save_note', 'false')"));

$form->add_html_element(new button($cmdCancel, "javascript:document.location='index.php';"));


require($GO_THEME->theme_path.'header.inc');
echo $form->get_html();

require($GO_THEME->theme_path.'footer.inc');	